import request from "@/utils/request";

/**
 * 搜索
 * @param {string} name
 * @returns
 */
export function adminSearch(name) {
    return request.post(`/adminEntity/adminSearch?name=${name}`);
}

/**
 * 登录
 * @param {string} account
 * @param {string} password
 * @param {string} code
 * @returns
 */
export function adminLogin(account, password, code) {
    return request.post(`/adminEntity/adminLogin?account=${account}&password=${password}&code=${code}`);
}

/**
 * 列表分页
 * @param {string} page
 * @param {string} pageSize
 * @returns
 */
export function adminListPage(page, pageSize) {
    return request.post(`/adminEntity/adminListPage?page=${page}&pageSize=${pageSize}`);
}

/**
 * 编辑
 * @param {object} params 管理员表
 * @param {number} params.id 主键
 * @param {string} params.account 账号
 * @param {string} params.password 密码
 * @param {string} params.avatar 头像
 * @param {string} params.name 姓名
 * @param {string} params.role 角色
 * @returns
 */
export function adminEditor(params) {
    return request.post(`/adminEntity/adminEditor`, params);
}

/**
 * 删除
 * @param {string} id
 * @returns
 */
export function adminDelete(id) {
    return request.post(`/adminEntity/adminDelete?id=${id}`);
}

/**
 * 新增
 * @param {object} params Admin
 * @param {string} params.account
 * @param {string} params.password
 * @param {string} params.avatar
 * @param {string} params.name
 * @returns
 */
export function adminAppend(params) {
    return request.post(`/adminEntity/adminAppend`, params);
}

/**
 * 列表
 * @returns
 */
export function adminList() {
    return request.get(`/adminEntity/adminList`);
}


/**
 * 获取
 * @param {string} id
 * @returns
 */
export function adminId(id) {
    return request.post(`/adminEntity/adminId?id=${id}`);
}

/**
 * 修改密码
 * @param {string} id
 * @param {string} oldPwd
 * @param {string} newPwd
 * @returns
 */
export function adminChangePass(id, oldPwd, newPwd) {
    return request.post(`/adminEntity/adminChangePass?id=${id}&oldPwd=${oldPwd}&newPwd=${newPwd}`);
}